'''
Created on Jan 17, 2010

@author: roman

$Id: lasttwitterid.py 17 2010-01-19 16:57:16Z sigizmund $
'''


from google.appengine.ext import db

class LastTwitterId(db.Model):
    user = db.StringProperty(required = True)
    statusId = db.StringProperty(required = True)
    obtainedAt = db.DateTimeProperty(auto_now = True)
    hasBacklog = db.BooleanProperty(default = False)
    

def clearAll():
    statuses = LastTwitterId.all()
    for s in statuses:
        s.delete()
    
def addTwitterId(username):
    twid = LastTwitterId(user = username, statusId = '1')
    twid.save()

def haveTwitterId(username):
    ids = LastTwitterId.all()
    ids.filter("user = ", username)
    return len(ids.fetch(1)) > 0